function sub_x = SaNSDE(sub_x, sample_y, best_x, index1, maxIteration,dim, LB, UB, Fun)

[~, bestIndex] = min(sample_y);    % 获得全局最优值以及对应的种群向量
globalBest = sub_x(bestIndex,:);

p1 = 0.5;p3 = 0.5;    % 策略学习初始化值的设置
ns1 = 0;ns2 = 0;nf1 = 0;nf2 = 0;
fns1 = 0;fns2 = 0;fnf1 = 0;fnf2 = 0;
CRm = 0.5;
CRQ = normrnd(CRm,0.1,[size(sub_x,1),1]);
CRRecord = [];
RecRecord = [];
popsize = size(sub_x,1);

for time = 1 : maxIteration
    for i = 1 : popsize
        if rand() >= p3    % 突变
            F = Cauchy_rand(0,1);
            tag1 = 1;
        else
            F = normrnd(0.5,0.3);    % 生成1个高斯随机数
            tag1 = 2;
        end
        if rand() <= p1
            r = randperm(popsize, 3);   %策略1
            mutantPos = sub_x(r(1),:) + F * (sub_x(r(2),:) - sub_x(r(3),:));    %在1~pop中随机选择3个数组成一个数组
            tag0 = 1;
        else
            r = randperm(popsize, 2);   %策略2
            mutantPos = sub_x(i,:) + F * (globalBest - sub_x(i,:)) + F * (sub_x(r(1),:) - sub_x(r(2),:));
            tag0 = 2;
        end

        jj = randi(dim);  % 选择至少一维发生交叉
        CR = CRQ(i,1);
        for d = 1:dim
            if rand() < CR || d == jj
                crossoverPos(d) = mutantPos(d);
            else
                crossoverPos(d) = sub_x(i,d);
            end
        end

        crossoverPos(crossoverPos>UB) = UB;    % 检查是否越界
        crossoverPos(crossoverPos<LB) = LB;

        best_x(:,index1) = crossoverPos;    % 小于原有值就更新,同时更新ns1,ns2,nf1,nf2
        evalNewPos = Fun(best_x');    % 将突变和交叉后的变量重新评估
        evalNewPos = evalNewPos';
        if evalNewPos < sample_y(i)
            if tag0 == 1
                ns1 = ns1 + 1;
            elseif tag0 == 2
                ns2 = ns2 + 1;
            end
            if tag1 == 1
                fns1 = fns1 + 1;
            elseif tag1 == 2
                fns2 = fns2 + 1;
            end
            CRRecord = [CRRecord;CR]; 
            RecRecord = [RecRecord;(sample_y(i) - evalNewPos)];
            sub_x(i,:) = crossoverPos;
            sample_y(i) = evalNewPos;
        else
            if tag0 == 1
                nf1 = nf1 + 1;
            elseif tag0 == 2
                nf2 = nf2 + 1;
            end
            if tag1 == 1
                fnf1 = fnf1 + 1;
            elseif tag1 == 2
                fnf2 = fnf2 + 1;
            end
        end
    end
    [~, bestIndex] = min(sample_y);
    globalBest = sub_x(bestIndex,:);

    % F,策略的学习
    if mod(time,50) == 0
        p1 = (ns1 * (ns2 + nf2)) / (ns2 * (ns1 + nf1) + ns1 * (ns2 + nf2));
        ns1 = 0;ns2 = 0;nf1 = 0;nf2 = 0;
        p3 = (fns1 * (fns2 + fnf2)) / (fns2 * (fns1 + fnf1) + fns1 * (fns2 + fnf2));
        fns1 = 0;fns2 = 0;fnf1 = 0;fnf2 = 0;
    end

    % CR的更新
    if mod(time,25) == 0
        wk = RecRecord ./ sum(RecRecord);
        CRm = sum(wk .* CRRecord);
        CRRecord = [];
        RecRecord = [];
    end
    if mod(time,5) == 0
        CRQ = normrnd(CRm,0.1,[popsize,1]);
    end
end
end